<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <% include header.ejs%>
  <link rel="stylesheet" href="<%= module_dir%>/static/css/login.css">
  <title>博客后台登录</title>
</head>

<body>

  <body class="text-center">
    <div class="form-signin">
      <h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
      <label for="inputName" class="sr-only">用户名</label>
      <input type="email" id="inputName" class="form-control" placeholder="请输入账号" required autofocus>
      <label for="inputPassword" class="sr-only">密码</label>
      <input type="password" id="inputPassword" class="form-control" placeholder="请输入密码" required>
      <div class="checkbox mb-3">
        <label>
          <input type="checkbox" value="remember-me"> Remember me
        </label>
      </div>
      <button class="btn btn-lg btn-primary btn-block" type="submit">登陆</button>
      <p class="mt-5 mb-3 text-muted">&copy; 2017-2018</p>
    </div>
  </body>
  <script>
     var module_dir = "<%= module_dir%>"
  </script>
  <script>
    $(function () {
      $('.btn').on('click', function () {
        let name = $('#inputName').val();
        let password = $('#inputPassword').val();
        if (name && password) {
          $axios.post(`${module_dir}/api/login`,{
            name,
            password
          }).then(resp=>{
            console.log(resp);
          })
        } else {
          alert('请输入账号或密码')
        }
      })
    })
  </script>
</body>

</html>